require "trifle/ruby/wrappers/deep_merge"

module Trifle
  module Ruby
    class Config
      def self.load
        self.default.deep_merge( self.config )
      end

      def self.config
        YAML.load( ERB.new( File.read( File.join( "config", "trifle-ruby.yml" ) ) ).result ) rescue {}
      end
      
      def self.is_quiet?
        environment = ::Rails.env || ENV["rack_env"] || ENV["RAILS_ENV"]
        self.load[environment]['quiet']
      end

      def self.default
        YAML.load_file( File.join( File.dirname( __FILE__ ), "default.yml" ) )
      end

      def self.defaults
        {
          ignored_constants: "Rails::Console",
          ignored_executables: "irb,rspec",
          ignored_tasks: "about,assets:clean,assets:clobber,assets:environment,assets:precompile,assets:precompile:all,db:create,db:drop,db:fixtures:load,db:migrate,db:migrate:status,db:rollback,db:schema:cache:clear,db:schema:cache:dump,db:schema:dump,db:schema:load,db:seed,db:setup,db:structure:dump,db:version,doc:app,log:clear,middleware,notes,notes:custom,rails:template,rails:update,routes,secret,spec,spec:features,spec:requests,spec:controllers,spec:helpers,spec:models,spec:views,spec:routing,spec:rcov,stats,test,test:all,test:all:db,test:recent,test:single,test:uncommitted,time:zones:all,tmp:clear,tmp:create"
        }
      end
    end
  end
end
